package cz.tpj.database.akcia;

import static org.junit.Assert.*;

import org.junit.Test;

import cz.tpj.database.obrazky.Obrazok;
import cz.tpj.util.ErrorDatabase;

public class AkciaTest {
	@Test
	public void testAkcia() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);		
		
		assertEquals("ID1", o2.getId());
		assertEquals("action1", o2.getNazov());
		assertEquals("the test action", o2.getKratkyPopis());
		assertEquals("first action of the first test", o2.getDlhyPopis());
		assertEquals("27.12.1984", o2.getDatum());
		assertEquals("Opava", o2.getMesto());
		assertEquals("park", o2.getBodZaujmu());
		assertEquals("John Black", o2.getZamestnanec());
		assertEquals(o1, o2.getObrazky());
	}

	@Test
	public void testId() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setId("ID2");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("ID2", o2.getId());		
	}

	@Test
	public void testNazov() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setNazov("action2");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("action2", o2.getId());		
	}

	@Test
	public void testKratkyPopis() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setNazov("the second test action");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("the second test action", o2.getNazov());		
	}

	@Test
	public void testDlhyPopis() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setDlhyPopis("second action of the first test");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("second action of the first test", o2.getDlhyPopis());		
	}

	@Test
	public void testDatum() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setDatum("1.1.2008");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("1.1.2008", o2.getDatum());		
	}
	
	@Test
	public void testMesto() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setMesto("Ostrava");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("Ostrava", o2.getMesto());		
	}

	@Test
	public void testZamestnanec() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setZamestnanec("Peter White");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("Peter White", o2.getZamestnanec());		
	}

	@Test
	public void testBodZaujmu() {
		Obrazok o1 = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		try {
			o2.setBodZaujmu("street");
		} catch (ErrorDatabase e) {
			e.printStackTrace();
		}
		
		assertEquals("street", o2.getBodZaujmu());
	}

	@Test
	public void testObrazky() {
		Obrazok o1 = new Obrazok();
		Obrazok pic = new Obrazok();
		Akcia o2 = new Akcia("ID1", "action1", "the test action", "first action of the first test","27.12.1984","Opava","park","John Black",o1);
		
		o2.setObrazky(pic);
		
		assertEquals(pic, o2.getObrazky());
	}
}
